import {
	request
} from "../utils/request";

// 获取用户信息
export const getUserInfo = () => {
	return request({
		url: '/users/info',
		method: 'GET'
	})
}

// 更新用户信息
export const updateUserInfo = (data) => {
	return request({
		url: '/users/update',
		method: 'PUT',
		data
	})
}

// 获取我的收藏
export const getMyCollections = (userId) => {
	return request({
		url: `/users/getCollections?_id=${userId}`,
		method: 'GET'
	})
}

// 加入收藏/取消收藏
export const toggleCollection = (userId, foodId) => {
	return request({
		url: '/foods/collect',
		method: 'PUT',
		data: {
			userId,
			foodId
		}
	})
}

// 判断菜谱是否已收藏
export const checkCollection = (userId, foodId) => {
	return request({
		url: `/foods/isCollect?userId=${userId}&foodId=${foodId}`,
		method: 'GET'
	})
}

// 添加浏览记录
export const addBrowseRecord = (foodId) => {
	return request({
		url: '/foods/browse',
		method: 'POST',
		data: {
			foodId
		}
	})
}

